package com.flipdf2;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.flipdf2.render.RenderException;

public class MainFrame extends JFrame {

	public MainFrame() {
	}

	private JPanel createToolPanel() {
		JPanel jPanel = new JPanel();
		return jPanel;
	}

	private JComboBox createZoomButton() {
		JComboBox comboBox = new JComboBox();
		comboBox.addItem("50");
		comboBox.addItem("100");
		comboBox.addItem("150");
		comboBox.setSelectedItem("100");
		return comboBox;
	}

	public static void main(String[] args) throws RenderException {
		String path = "c:/1.pdf";

		JFrame frame = new JFrame();
		JScrollPane scrollPane = new JScrollPane();

		Document doc = new Document();

		PageSetup setup = new PageSetup(Paper.A4);
		Page page = new Page(setup);
		page.addStamp(new PDFStamp(new File(path), 1));

		PageSetup setup2 = new PageSetup(Paper.A5);
		Page page2 = new Page(setup2);
		page2.addStamp(new PDFStamp(new File("c:/2.pdf"), 1));

		doc.addPage(page);
		doc.addPage(page2);
		DocumentPanel documentPanel = new DocumentPanel(scrollPane, doc);
		documentPanel.setShowType(DocumentPanel.MULTI_PAGE);

		frame.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent evt) {
				System.exit(0);
			}
		});

		frame.setPreferredSize(new Dimension(1024, 768));

		scrollPane.setViewportView(documentPanel);

		JPanel toolPanel = new JPanel();
		JComboBox zoomComboBox = new JComboBox();
		zoomComboBox.addItem("50");
		zoomComboBox.addItem("100");
		zoomComboBox.addItem("150");
		zoomComboBox.setSelectedItem("100");
		toolPanel.add(zoomComboBox);
		zoomComboBox.addActionListener(documentPanel.getZoomAction());

		frame.getContentPane().setLayout(new BorderLayout());
		frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
		frame.getContentPane().add(toolPanel, BorderLayout.NORTH);
		frame.pack();
		frame.setVisible(true);
	}
}
